package app;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;

import KUtilities.KSwing;

public class MenuBar extends JMenuBar {
	private static final long serialVersionUID = 1L;
	
	public MenuBar(SMSPanel smsPanel) {
		JMenu file=new JMenu("File");
		file.setMnemonic('F');
		JMenuItem loginMenu=new JMenuItem("Login");
		loginMenu.setMnemonic('L');
		loginMenu.setAction(smsPanel.getLoginLogoutAction());
		JMenuItem exitMenu=new JMenuItem("Exit");
		exitMenu.setMnemonic('E');
		exitMenu.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent ae){
				System.exit(0);
			}
		});
		file.add(loginMenu);
		file.add(exitMenu);
		
		JMenu options=new JMenu("Options");
		options.setMnemonic('O');
		JMenu themes=new JMenu("Themes");
		themes.setMnemonic('T');
		final String laf[]=KSwing.getLookAndFeels();
		for(int i=0;i<laf.length;i++){
			final JMenuItem item=new JMenuItem(laf[i]);
			themes.add(item);
			item.addActionListener(new ActionListener(){
				public void actionPerformed(ActionEvent ae){
					KSwing.setLookAndFeel(item.getText());
				}
			});
		}
		options.add(themes);
		
		JMenu help=new JMenu("Help");
		JMenuItem about=new JMenuItem("About");
		help.setMnemonic('H');
		about.setMnemonic('A');
		help.add(about);
		about.addActionListener(new About().getAboutAction());
		
		add(file);
		add(options);
		add(help);
	}

}
